// pages/score/score.js
var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    score:[],
    semeitem:1,
    options: [ {
      city_id: '2',
        city_name: '2017~2018下'
    }, {
      city_id: '3',
        city_name: '2018~2019上'
    }
      , {
        city_id: '4',
        city_name: '2018~2019下'
      },
      {
        city_id: '5',
        city_name: '2019~2020上'
      },
      {
        city_id: '6',
        city_name: '2019~2020下'
      }
     
    ],
    selected: {}

  },
  change(e) {
    this.setData({
      selected: { ...e.detail }
      
    })
    wx.showToast({
      // title: `${this.data.selected.id} - ${this.data.selected.name}`,
      icon: 'success',
      duration: 1000
    })
    console.log(e.detail.id)
    var semeitem = e.detail.id;
    var sid = app.globalData.sid;
    var that=this
    wx.request({
      url: 'https://smart.songblog.top/queryScoreBySemeItem',
      data: {sid,semeitem},
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function(res) {
        console.log(res);
        that.setData({
          score:res.data
        })
      },
      fail: function(res) {},
      complete: function(res) {},
    })



  },
  close() {
    // 关闭select
    this.selectComponent('#select').close()
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
this.getScore();
  },

getScore:function(){
  var that=this
  var sid = app.globalData.sid;
  var semeitem=this.data.semeitem;
wx.request({
  url: 'https://smart.songblog.top/queryScoreBySemeItem',
  data: {sid,semeitem},
  header: {},
  method: 'GET',
  dataType: 'json',
  responseType: 'text',
  success: function(res) {
    console.log(res);
    that.setData({
      score:res.data
    })
  },
  fail: function(res) {},
  complete: function(res) {},
})
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})